﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Wusong.Dal.Inf
{
    public interface IRawDAO
    {
        #region Insert
        object Insert(DataRow dr);
        object Insert(DataTable dt);
        object Insert(DataSet ds);
        #endregion

        #region update
        void Update(DataRow dr);
        void Update(DataTable dt);
        void Update(DataSet ds);
        #endregion

        #region Query
        object Query(IDbCommand command, IEnumerable<IDbDataParameter> parms);
        #endregion

        #region trans
        void BeginTran();
        void EndTran();
        #endregion

    }

    public interface IObjDAO<T> where T : class,
        new()//约束T类型必须可以实例化
    {
        T LoadSingleEntity(Func<T, bool> whereLambda);
        //根据条件获取实体对象集合
        IQueryable<T> LoadEntites(Func<T, bool> whereLambda);

        //根据条件获取实体对象集合分页
        IQueryable<T> LoadEntites(Func<T, bool> whereLambda, int pageIndex, int pageSize, out int totalCount);

        //增加
        T AddEntity(T entity,bool autoFlush);

        //更新
        T UpdateEntity(T entity);

        //删除
        bool DelEntity(T entity);

        //根据条件删除
        bool DelEntityByWhere(Func<T, bool> whereLambda);

        #region trans
        void BeginTran();
        void EndTran();
        #endregion

    }
}
